package Examin.WangYi2;

import java.util.Scanner;

public class 小红的数组修改 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int p = scanner.nextInt(); // p>=1 <=10
        int x = scanner.nextInt();
        int[] nums = new int[n];
        int sum = 0;  //数组初始和
        for(int i = 0; i < n; i++){
            nums[i] = scanner.nextInt();
            sum += nums[i];
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            int num = nums[i];  //取第一个数
            int yushu = sum%x ; //取余数
            int diff = yushu == 0 ? 0 : x-yushu;  //向上倍数 差的多少
            /**
             * 余数可以看出当前和 x的倍数差多少，如果向上则，需要增加 余数差 + n * x才能构成倍数
             * 向下 需要减少余数差 减n*x才能构成倍数
             * */
            int up = diff + num;
            int down = num - diff;
            if(diff!=0){
                if(up<=p){
                    res++;
                }
                if(down<=p && down>=1){
                    res++;
                }
            }
            //若当前值比p小要增大
            while(up<=p){
                if(up+x <=p){
                    up+=x;
                    res++;
                }else{
                    break;
                }
            }
//            //若当前值比p大要减小
//            while(down>p || down>=1){
//                if(down-x>=1){
//                    down-=x;
//                    if(down<=p){
//                        res++;
//                    }
//
//                }else{
//                    break;
//                }
//            }

//            for (int j = 1; j <= p; j++) {
//                //更改的数和原数不相等
//                if(j!=num){
//                    int currSum = sum + j-num;
//                    if(currSum%x==0){
//                        res++;
//                    }
//                }
//            }
        }
        System.out.println(res);


    }

}
